package com.golxen.framework.PBPacket;

import com.google.protobuf.AbstractMessage.Builder;
import com.google.protobuf.Message;

public class PBPacketUtils {

	public static PBPacket buildMessage(int code, Builder<?> messageBuilder) {
		return buildMessage(code, messageBuilder.build());
	}

	public static PBPacket buildMessage(int code, Message message) {
		PBPacket response = new PBPacket(code, -1);
		response.setMessage(message);
		return response;
	}

	public static PBPacket buildMessageByte(int code, byte[] data) {
		PBPacket response = new PBPacket(code, -1);
		response.setBytes(data);
		return response;
	}

	public static PBPacket buildMessageByte(int code, long userId, byte[] data) {
		PBPacket response = new PBPacket(code, userId);
		response.setBytes(data);
		return response;
	}

	public static PBPacket buildMessageByte(int code, long userId, int byteLength, byte[] data) {
		PBPacket response = new PBPacket(code, userId);
		response.setByteLength(byteLength);
		response.setBytes(data);
		return response;
	}

	public static PBPacket buildMessage(int code, long client, Builder<?> messageBuilder) {
		PBPacket response = new PBPacket(code, client);
		response.setMessage(messageBuilder.build());
		return response;
	}

	public static PBPacket buildMessage(int code, Object object) {
		PBPacket response = new PBPacket(code, object);
		return response;
	}

	public static PBPacket buildMessage(int code) {
		PBPacket response = new PBPacket(code);
		return response;
	}
}
